<?php
set_include_path('/alidata/www/xinjieco/auto/');


require_once "class/mysql_connect.php";
require_once "class/function_curl.php";
require_once "class/function_cutwords.php";
require_once "class/water.php";
require_once "class/cutphoto.php";

require_once "class/function_html2ubb.php";
require_once "class/function_savedata.php";


set_time_limit(0);
$time = time();
$now_day = date(Ymd);
$is_aid = 0;




$viewres = mysql_fetch_array(mysql_query("SELECT t1.*, t2.fid,type FROM cdb_xinjieco_auto_list t1, cdb_xinjieco_auto_listres t2 
										WHERE t1.status = '0' AND t1.fid = t2.fid AND t2.type = 'ifeng_auto'  ORDER BY id LIMIT 1"));
if ($viewres) {
	


	$fid = $viewres[fid];

	$outpage = $viewres[res];

	$page_res = get_url($outpage);

	//匹配操作

	$title = str_substr('<h1>', '</h1>', $page_res);

	$content = str_substr("<div id=\"artical_real\">", "<div class=\"clear\">", $page_res);


	//分页处理
	$page_point = ".shtml";
	$page_exp = explode($page_point, $outpage);


	//处理10页
	for ($i=1; $i < 10; $i++) { 
		$page_unm = substr($page_exp[0], -1) + $i;
		$paging = substr($page_exp[0], 0, -1).$page_unm.$page_point; //新页面
		$new_page = get_url($paging);
		$new_content = str_substr("<div id=\"artical_real\">", "<div class=\"clear\">", $new_page);

		if ($new_content) {
			$content = $content."<br/><br/>".$new_content;
		}else{
			break;
		}
	}

	/*
	数据过滤 ...
	*/




	$title = strtr_words($title);

	$content = strtr_words($content);

	$content = html2ubb($content, $fid);

	$title = trim(strip_tags($title));
	
	if ($title && $content) {
		//数据入库
		$msg = save_data(($title), trim(addslashes($content)), $fid, '1', $is_aid);
	}else{
		$msg = " —— $viewres[id]数据为空，跳过<br/>";
	}

	mysql_query("UPDATE cdb_xinjieco_auto_list SET status = '1' WHERE id = '$viewres[id]'");


	echo $msg;


}



